package com.tusuo.stds.ui.integrity;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.tusuo.stds.MyApp;
import com.tusuo.stds.R;
import com.tusuo.stds.di.DaggerScope;
import com.tusuo.stds.di.Injector;
import com.tusuo.stds.rest.ApiHelper;
import com.tusuo.stds.rest.Complete;
import com.tusuo.stds.rest.LevelResult;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.ViewById;

import java.util.List;

/**
 * Created by developer on 17-8-30.
 * 知识完整度Fragment
 */

@EFragment(R.layout.frag_integrity_level_result)
public class IntegrityResultFragment extends Fragment{

    @ViewById(R.id.frag_integrity_result_list)
    ListView mListView;


    @FragmentArg("levelId")
    int mLevelId;
    @FragmentArg("levelType")
    int mLevelType;
    @FragmentArg("levelResult")
    LevelResult levelResult;

    private List<LevelResult.GroupItem> mData;

    @AfterViews
    void initData() {
        mData = levelResult.GroupList;

        mListView.setAdapter(new IntegrityResultAdapter(getActivity(),mData));
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(getActivity(),IntegrityDetailActivity_.class);
                    intent.putExtra("dataId",mLevelId);
                    intent.putExtra("type",mLevelType);
                    intent.putExtra("completeId",mData.get(position).Id);
                    startActivity(intent);
            }
        });

    }

}
